package org.utnrepasa.net.util;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * Representa un jugador en una partida indicando si es creador, si es el turno, 
 * cantidad de preguntas contestadas, cantidad de preguntas contestadas
 * correctamente, rondas ganadas y cantidad de preguntas contestadas
 * por ronda.
 *
 * @author Parisi Germán
 * @version 1.2
 */
public class Player extends User implements Serializable {

	private static final long serialVersionUID = 1004;
    /**
     * Una bandera que indica si es el creador.
     */
    private boolean creator;
    /**
     * Una bandera que indica si es el turno.
     */
    private boolean turn;
    /**
     * Cantidad de rondas ganadas.
     */
    private int roundsWon;
    /**
     * Cantidad de preguntas contestadas.
     */
    private int countQuestionsAnswered;
    /**
     * Cantidad de preguntas contestadas correctamente.
     */
    private int countQuestionsAnsweredCorrectly;
    /**
     * Este Array representa la cantidad de preguntas respondidas correctamente
     * por ronda. Para acceder al mismo, hacer uso del método
     * getQuestionAnsweredCorrectly(int ronda).
     */
    private ArrayList<Integer> questionsAnsweredCorrectly;

    public Player(int id, String name) {
        this(id, name, false);
        this.questionsAnsweredCorrectly = new ArrayList<Integer>();
    }

    public Player(int id, String name, boolean creator) {
        super(id, name);
        this.creator = creator;
    }

    public void addQuestionAnsweredCorrectly(int count) {
        this.questionsAnsweredCorrectly.add(count);
    }

    public boolean isCreator() {
        return creator;
    }

    public boolean isTurn() {
        return turn;
    }

    public int getRoundsWon() {
        return roundsWon;
    }

    public int getCountQuestionsAnswered() {
        return countQuestionsAnswered;
    }

    public int getCountQuestionsAnsweredCorrectly() {
        return countQuestionsAnsweredCorrectly;
    }

    public int getQuestionAnsweredCorrectly(int round) {
        return questionsAnsweredCorrectly.get(round);
    }

    public void setCreator(boolean creator) {
        this.creator = creator;
    }

    public void setTurn(boolean turn) {
        this.turn = turn;
    }

    public void setRoundsWon(int roundsWon) {
        this.roundsWon = roundsWon;
    }

    public void setCountQuestionsAnswered(int questionsAnswered) {
        this.countQuestionsAnswered = questionsAnswered;
    }

    public void setCountQuestionsAnsweredCorrectly(int questionsAnsweredCorrectly) {
        this.countQuestionsAnsweredCorrectly = questionsAnsweredCorrectly;
    }
}
